﻿using MD5Hash;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace Dal
{
    public class Dengdal
    {
        public Dengdal(Hotext hotext)
        {
            Hotext = hotext;
        }

        public Hotext Hotext { get; }
        public int dadd(Dengmodel dengmodel)
        {
            dengmodel.Mima = dengmodel.Mima.GetMD5();
            Hotext.dengmodels.Add(dengmodel);
            return Hotext.SaveChanges();
        }
        public Dengmodel getbyid(int id)
        {
            return Hotext.dengmodels.Where(x => x.Id == id).FirstOrDefault();
        }
        public Dengmodel getbyname(string shouji)
        {
            return Hotext.dengmodels.Where(x => x.Shouji == shouji).FirstOrDefault();
        }
        public List<Dengmodel> dshow()
        {
            return Hotext.dengmodels.ToList();
        }
    }
}
